package com.handinfo.android.ui.window;

import java.io.DataInputStream;
import java.io.IOException;
import java.util.ArrayList;

import android.graphics.Bitmap;

import com.handinfo.android.DWGameManager;
import com.handinfo.android.core.graphics.DWFont;
import com.handinfo.android.core.graphics.DWGraphics;
import com.handinfo.android.game.GameCarbon;
import com.handinfo.android.game.GameMessage;
import com.handinfo.android.game.IconManger;
import com.handinfo.android.game.item.Item;
import com.handinfo.android.game.item.ItemConstants;
import com.handinfo.android.ui.IUIWindows;
import com.handinfo.android.ui.UIWindows;
import com.handinfo.android.uicontrols.DWControlTools;
import com.handinfo.android.uicontrols.DWControlsManager;
import com.handinfo.android.uicontrols.DWExternalDraw;
import com.handinfo.android.uicontrols.DWListener;
import com.handinfo.android.uicontrols.controls.DWBackground;
import com.handinfo.android.uicontrols.controls.DWButton;
import com.handinfo.android.uicontrols.controls.DWFrame;
import com.handinfo.android.uicontrols.controls.DWImageBox;
import com.handinfo.android.uicontrols.controls.DWLabel;
import com.handinfo.android.uicontrols.controls.DWListSubItem;
import com.handinfo.android.uicontrols.controls.DWListbox;
import com.handinfo.android.uicontrols.controls.DWMessageBox;
import com.handinfo.android.uicontrols.controls.DWPopMenu;
import com.handinfo.android.uicontrols.controls.DWTextbox;
import com.handinfo.android.uicontrols.controls.DWTitle;
//import com.handinfo.android.utils.ChannelOperation;
import com.handinfo.android.utils.Tools;

public class UIGameCarbonWindow implements IUIWindows
{
	Bitmap m_cr_tc = null; // 退出叉键按钮的图片
	Bitmap m_cr_but = null; ///按钮点击前图片
	Bitmap m_cr_but_1 = null;///按钮点击后抬起前图片
	Bitmap m_cr_grid_ima = null;
	Bitmap m_cr_tongguan_tit = null;
	Bitmap m_cr_buy = null;
	Bitmap m_cr_buy_1 = null;
	Bitmap m_cr_tit = null;
	public Bitmap m_cr_xxbj = null; ///每个副本的小背景
	Bitmap m_cr_xxbj_xz = null;
	Bitmap m_cr_down = null; ///下面的一条的图片
	DWFrame m_fuben_frame = null; ////画布
	DWTitle m_fuben_tit;/////标题
	DWImageBox m_shuzi;

	DWBackground m_xbj_bg;//////小背景
	DWBackground m_xxbj_bg[];
	DWBackground m_xiamian_bg;
	DWImageBox m_tit_ima_tongguan;
	DWTextbox m_textbox[];
	DWTextbox m_jl_tb;
	public DWTextbox m_jingli_textbox;
	DWImageBox m_tuichu_ima;
	DWImageBox m_tuichu_ima_1;
	DWImageBox m_tit_ima;
	DWListbox m_listbox;
	DWButton m_carbon_but[];
	DWButton m_goumai_but;
	DWTextbox m_goumai_text;
	DWPopMenu m_fuben_pm = null;
	public GameCarbon m_gcb = null; ///副本对象
	DWFrame m_pm_zudui_frame = null;///组队出来的对话框的画布
	DWPopMenu m_carbon_pm = null;
	int m_gamecarbon_index_1;//通过它的值可以知道是哪个副本在做操作
	DWListSubItem m_lsi_1 = null;
	DWListSubItem m_lsi = null;
	private byte m_carbon_state = 0;//精力颜色状态

	/**
	 * 接收副本界面开启
	 * @param dis
	 * @throws IOException
	 * //
	 */
	public final void recvGameCarbonOpen(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		byte size = dis.readByte();//副本数量
		if (size > 0) {
			ArrayList<GameCarbon> gcl = DWGameManager.getInstance().m_role.m_game_carbon;
			gcl.clear();
			for (byte i = 0; i < size; i++) {
				GameCarbon gc = new GameCarbon();
				gc.read(dis);
				DWGameManager.getInstance().m_role.m_game_carbon.add(gc); //////添加对象
//				Tools.debugPrintln("第"+i+"个副本状态："+gcl.get(i).getStatus());
			}
			m_carbon_state = dis.readByte();
//			Tools.debugPrintln("进入打开副本"+m_carbon_state);
			UIWindows.getInstance().m_fuben.open((byte) 0);
		}
	}

	byte m_count;
	private DWMessageBox m_jingli_mb;

	public final void recvGameCarbonBuy(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);

		byte count = dis.readByte();
		int m_yuanbao = dis.readInt();
		m_count = count;
		Tools.debugPrintln("次数：" + count);

		m_jingli_mb = new DWMessageBox("温馨提示", "您确定要消耗" + m_yuanbao + "元宝购买50点精力吗？", "购买", "取消");
//				+ DWControlTools.CHANGE_ROW + "购买50精力，需要花费"+m_yuanbao+"元宝。"+DWControlTools.CHANGE_ROW+
//				"<mark c=ffc001>"+"还能购买精力"+count+"次"+"</mark>",
		switch (count) {
			case 0:
				m_jingli_mb = new DWMessageBox("温馨提示", "您确定要消耗<mark c=FFEE55>" + m_yuanbao + "</mark>元宝购买50点精力吗？",
						"购买", "取消");
				break;
			case 1:
				m_jingli_mb = new DWMessageBox("温馨提示", "您确定要消耗<mark c=FFCC55>" + m_yuanbao + "</mark>元宝购买50点精力吗？",
						"购买", "取消");
				break;
			case 2:
				m_jingli_mb = new DWMessageBox("温馨提示", "您确定要消耗<mark c=FFAA55>" + m_yuanbao + "</mark>元宝购买50点精力吗？",
						"购买", "取消");
				break;
			case 3:
				m_jingli_mb = new DWMessageBox("温馨提示", "您确定要消耗<mark c=FF8855>" + m_yuanbao + "</mark>元宝购买50点精力吗？",
						"购买", "取消");
				break;
			case 4:
				m_jingli_mb = new DWMessageBox("温馨提示", "您确定要消耗<mark c=FF5555>" + m_yuanbao + "</mark>元宝购买50点精力吗？",
						"购买", "取消");
				break;

			default:
				break;
		}
		DWControlsManager.getInstance().addControl(m_jingli_mb);
		m_jingli_mb.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_jingli_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
//					if(m_count >0)
//					{
//						DWGameManager.getInstance().getSendMessage().sendGameCarbonGVim(50);
//					}
//					else
//					{
//						DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您当日的购买精力次数已经耗尽。");
//					}
					DWGameManager.getInstance().getSendMessage().sendGameCarbonGVim(50);
				}
				else if (m_jingli_mb.getResult() == DWMessageBox.SOFTKEY_BACK)
				{
				}
				DWControlsManager.getInstance().removeControl(m_jingli_mb);
			}
		});
	}

	/**
	 * 副本通关提示
	 * @param dis
	 * @throws IOException
	 */
	public void recvGameCarbonFinish(DataInputStream dis) throws IOException
	{
		String gcName = dis.readUTF();
		String gcReward = dis.readUTF();

		final DWMessageBox m_mb = new DWMessageBox("胜利", "恭喜您完成" + gcName + "!" + DWControlTools.CHANGE_ROW + "获得"
				+ gcReward + "!");
		m_mb.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {

				}
				else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
				}
			}
		});
	}

	/**
	 * 接收副本检测
	 * @param dis
	 */
	public void recvGameCarbonCheck(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		byte status = dis.readByte();
		Tools.debugPrintln("副本进入检测 : " + status);
	}

	/**
	 * 接收自动组队
	 * @param dis
	 * @throws IOException
	 */
	String info = null;

	public void recvGameCarbonAuto(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		final byte status = dis.readByte();
		info = dis.readUTF();
		Tools.debugPrintln("状态：" + status + "内容：" + info);
		open((byte) 1);
	}

	/**
	 * 副本增次
	 * @param dis
	 * @throws IOException
	 */
	public void recvGameCarbonAdd(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		dis.readByte();
	}

	/**
	 * 副本掉落详情
	 * @param dis
	 * @throws IOException
	 */
	public DWFrame m_lose_frame = null;
	public DWListbox m_lose_listbox;
	public GameCarbon m_gcb_1;
	public DWBackground m_ima_bg[];
	public DWImageBox m_lose_ima_dibu[];
	public DWImageBox m_lose_ima[];
	public DWTextbox m_lose_textbox[];
	public byte size1;
	public byte size2;
	public byte size3;
	Item[] itemsJ;
	Item[] itemsY;
	Item[] itemsT;
	Item m_final_item_1;
	Item m_final_item_2;
	Item m_final_item_3;
	int m_lsi_index;

	public void recvGameCarbonRewardDetails(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		int coin = dis.readInt(); // 副本奖励钱
		int exp = dis.readInt(); //副本奖励经验
		size1 = dis.readByte(); //副本金宝箱掉落物品数量
		itemsJ = new Item[size1];
		for (int i = 0; i < size1; i++) {
			Item item = new Item();
			item.m_key = dis.readUTF();
			item.m_name = dis.readUTF();
			item.m_iconId = dis.readShort();
			item.m_quality = dis.readByte();
			itemsJ[i] = item;
			Tools.debugPrintln("金箱子第" + i + "个道具：" + itemsJ[i].m_name);
		}
		size2 = dis.readByte(); //副本银宝箱掉落物品数量
		itemsY = new Item[size2];
		for (int i = 0; i < size2; i++) {
			Item item = new Item();
			item.m_key = dis.readUTF();
			item.m_name = dis.readUTF();
			item.m_iconId = dis.readShort();
			item.m_quality = dis.readByte();
			itemsY[i] = item;
			Tools.debugPrintln("银箱子第" + i + "个道具：" + itemsY[i].m_name);
		}
		size3 = dis.readByte(); //副本铜宝箱掉落物品数量
		itemsT = new Item[size3];
		for (int i = 0; i < size3; i++) {
			Item item = new Item();
			item.m_key = dis.readUTF();
			item.m_name = dis.readUTF();
			item.m_iconId = dis.readShort();
			item.m_quality = dis.readByte();
			itemsT[i] = item;
			Tools.debugPrintln("铜箱子第" + i + "个道具：" + itemsT[i].m_name);
		}

		Tools.debugPrintln("size1:" + size1 + "," + size2 + "," + size3);
		for (int i = 0; i < DWGameManager.getInstance().m_role.m_game_carbon.size(); i++) {
			m_xxbj_bg[i].setBackground(m_cr_xxbj);
		}
		Lose();
	}

	Bitmap m_cr_tit_ima = null;

	public void Lose()
	{
		if (DWControlsManager.getInstance().contains(m_lose_frame)) {
			if (m_lose_frame != null)
			{
				DWControlsManager.getInstance().removeControl(m_lose_frame);
			}
		}
		m_xxbj_bg[m_gamecarbon_index_1].setBackground(m_cr_xxbj);
		m_lose_frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER, true);
		m_lose_frame.setClickClose(false);
		DWControlsManager.getInstance().addControl(m_lose_frame);

		DWTitle m_lose_tit = new DWTitle("", m_lose_frame);
		m_lose_frame.addControl(m_lose_tit);
		DWImageBox m_tit_ima = new DWImageBox(m_cr_tit_ima);
		m_tit_ima.setNearAnchor(m_lose_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_lose_frame.addControl(m_tit_ima);

		DWImageBox m_tuichu_ima_1 = new DWImageBox(m_cr_tc);
		m_tuichu_ima_1.setNearAnchorUn(m_lose_tit, Tools.RIGHT_VCENTER,
				Tools.RIGHT_VCENTER, 0, 0);
		m_lose_frame.addControl(m_tuichu_ima_1);
		m_tuichu_ima_1.setTouchZoomIn(40, 40);
		m_tuichu_ima_1.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				DWControlsManager.getInstance().removeControl(m_lose_frame);
			}
		});

		DWBackground m_xbj = new DWBackground(m_lose_frame.getShowWidth() - 20, m_lose_frame.getShowHeight()
				- (m_lose_tit.getShowHeight() - 20) - 20);
		m_xbj.setNearAnchor(m_lose_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10 + (m_lose_tit.getShowHeight() - 20));
		m_lose_frame.addControl(m_xbj);

		DWBackground m_name_bg = new DWBackground(m_cr_xxbj, m_xbj.getShowWidth() - 10, 50);
		m_name_bg.setNearAnchor(m_xbj, Tools.LEFT_TOP, Tools.LEFT_TOP, 5, 5);
		m_lose_frame.addControl(m_name_bg);

		DWTextbox m_carbon_name = new DWTextbox(m_gcb_1.getName());
		m_carbon_name.setNearAnchor(m_name_bg, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_lose_frame.addControl(m_carbon_name);

		if (m_lose_frame.contains(m_lose_listbox) == true) {
			m_lose_frame.removeControl(m_lose_listbox);
		}
		m_lose_listbox = new DWListbox(m_name_bg.getShowWidth(), m_xbj.getShowHeight() - m_name_bg.getShowHeight() - 10);
		m_lose_listbox.setNearAnchor(m_name_bg, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 0);
		m_lose_listbox.setLineSpacing(10);
		m_lose_listbox.setShowBackgroundRect(false);
		m_lose_frame.addControl(m_lose_listbox);

		m_ima_bg = new DWBackground[itemsJ.length + itemsY.length + itemsT.length];
		m_lose_ima_dibu = new DWImageBox[itemsJ.length + itemsY.length + itemsT.length];
		m_lose_ima = new DWImageBox[itemsJ.length + itemsY.length + itemsT.length];
		m_lose_textbox = new DWTextbox[itemsJ.length + itemsY.length + itemsT.length];
		for (m_lsi_index = 0; m_lsi_index < (itemsJ.length + itemsY.length + itemsT.length); m_lsi_index++) {

			m_ima_bg[m_lsi_index] = new DWBackground(m_cr_xxbj, (m_lose_listbox.getShowWidth() - 10) / 2,
					(m_lose_listbox.getShowHeight() - 20) / 3);

			IconManger m_losr_icon = new IconManger();
			m_lose_ima_dibu[m_lsi_index] = new DWImageBox(m_cr_grid_ima);
			m_lose_ima[m_lsi_index] = new DWImageBox(m_cr_grid_ima);
			m_lose_ima_dibu[m_lsi_index].setNearAnchor(m_ima_bg[m_lsi_index], Tools.LEFT_TOP, Tools.LEFT_TOP,
					5, (m_ima_bg[m_lsi_index].getShowHeight() - m_lose_ima_dibu[m_lsi_index].getShowHeight()) / 2);
			m_lose_ima[m_lsi_index].setNearAnchor(m_ima_bg[m_lsi_index], Tools.LEFT_TOP, Tools.LEFT_TOP,
					5, (m_ima_bg[m_lsi_index].getShowHeight() - m_lose_ima[m_lsi_index].getShowHeight()) / 2);
			final int m_index = m_lsi_index;
			m_lose_ima[m_lsi_index].setTouchZoomIn(30, 30);
			m_lose_ima[m_lsi_index].addListener(new DWListener() {

				public void OnDoubleClick()
				{

				}

				public void OnClick()
				{
					Tools.debugPrintln("m_index:" + m_index);
					for (int i = 0; i < size1 + size2 + size3; i++)
					{
						m_ima_bg[i].setBackground(m_cr_xxbj);
						m_lose_ima[i].setSelect(false);
					}
					m_ima_bg[m_index].setBackground(m_cr_xxbj_xz);
					m_lose_ima[m_index].setSelect(true);
					if (m_index < size1)
					{
						m_final_item_1 = itemsJ[m_index];
						DiaoLuo(m_final_item_1.m_key);
					}
					else if (m_index + 1 > size1 && m_index < (size1 + size2))
					{
						m_final_item_2 = itemsY[m_index - size1];
						DiaoLuo(m_final_item_2.m_key);
					}
					else if (m_index + 1 > (size1 + size2 - 1) && m_index < (size1 + size2 + size3))
					{
						m_final_item_3 = itemsT[m_index - size1 - size2];
						DiaoLuo(m_final_item_3.m_key);
					}
				}
			});

			m_lose_textbox[m_lsi_index] = new DWTextbox("", m_ima_bg[m_lsi_index].getShowWidth()
					- m_lose_ima[m_lsi_index].getShowWidth() - 5);
			m_lose_textbox[m_lsi_index].setNearAnchor(m_lose_ima[m_lsi_index], Tools.LEFT_VCENTER, Tools.RIGHT_VCENTER,
					0, 0);
			if (m_lsi_index < itemsJ.length) {
				m_lose_ima[m_lsi_index].setImage(m_losr_icon.getIcon(itemsJ[m_lsi_index].m_iconId));
				m_lose_textbox[m_lsi_index].setText("<mark c=" + getcolor(itemsJ[m_lsi_index].m_quality) + ">"
						+ itemsJ[m_lsi_index].m_name + "</mark>"
						+ DWControlTools.CHANGE_ROW + "(金箱子)");

			}
			else if (m_lsi_index > itemsJ.length - 1
					&& m_lsi_index < (itemsJ.length + itemsY.length)) {
				m_lose_ima[m_lsi_index].setImage(m_losr_icon.getIcon(itemsY[m_lsi_index - itemsJ.length].m_iconId));
				m_lose_textbox[m_lsi_index].setText("<mark c="
						+ getcolor(itemsY[m_lsi_index - itemsJ.length].m_quality) + ">"
						+ itemsY[m_lsi_index - itemsJ.length].m_name + "</mark>"
						+ DWControlTools.CHANGE_ROW + "(银箱子)");
			}
			else {
				m_lose_ima[m_lsi_index].setImage(m_losr_icon
						.getIcon(itemsT[m_lsi_index - itemsJ.length - itemsY.length].m_iconId));
				m_lose_textbox[m_lsi_index].setText("<mark c="
						+ getcolor(itemsT[m_lsi_index - itemsJ.length - itemsY.length].m_quality) + ">"
						+ itemsT[m_lsi_index - itemsJ.length - itemsY.length].m_name
						+ "</mark>" + DWControlTools.CHANGE_ROW + "(铜箱子)");
			}

			if (m_lsi_index % 2 == 0) {
				m_lsi = new DWListSubItem();

				m_ima_bg[m_lsi_index].setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
				m_lsi.addControls(m_ima_bg[m_lsi_index]);
				m_lsi.addControls(m_lose_ima_dibu[m_lsi_index]);
				m_lsi.addControls(m_lose_ima[m_lsi_index]);
				m_lsi.addControls(m_lose_textbox[m_lsi_index]);
				if (m_lsi_index == itemsJ.length + itemsY.length + itemsT.length - 1) {
					m_lose_listbox.addSubItem(m_lsi);
				}
			}
			else {
				m_ima_bg[m_lsi_index].setNearAnchor(m_ima_bg[m_lsi_index - 1], Tools.LEFT_TOP, Tools.RIGHT_TOP, 10, 0);
				m_lsi.addControls(m_ima_bg[m_lsi_index]);
				m_lsi.addControls(m_lose_ima_dibu[m_lsi_index]);
				m_lsi.addControls(m_lose_ima[m_lsi_index]);
				m_lsi.addControls(m_lose_textbox[m_lsi_index]);
				m_lose_listbox.addSubItem(m_lsi);
			}
		}
	}

	public void DiaoLuo(String key)
	{
		DWGameManager.getInstance().getSendMessage().sendSeeItemInfos(0, key);
	}

	/**
	 * 更新副本的状态
	 * @param dis
	 * @throws IOException
	 */
	public void recvGameCarbonUpdate(DataInputStream dis) throws IOException
	{
		Tools.debugPrintln("进入更新副本的接收方法。");
		byte size = dis.readByte();
		if (size > 0) {
			ArrayList gcl = DWGameManager.getInstance().m_role.m_game_carbon;
			GameCarbon gc = null;
			for (int i = 0, j = 0; i < size; i++) {
				String key = dis.readUTF();
				byte status = dis.readByte();
				Tools.debugPrintln("第" + i + "个状态:" + status);
				for (j = 0; j < gcl.size(); j++) {
					gc = (GameCarbon) gcl.get(j);
					if (gc.getKey().equals(key)) {
						gc.updateStatus(status);
						continue;
					}
				}
			}
			m_carbon_state = dis.readByte();
		}
		for (int i = 0; i < DWGameManager.getInstance().m_role.m_game_carbon.size(); i++) {
			GameCarbon m_carbon_copy = DWGameManager.getInstance().m_role.m_game_carbon.get(i);
			if (m_carbon_copy.getStatus() == m_carbon_copy.STATUS_JOIN) {
				String cishu = "" + m_carbon_copy.getM_vim();
				switch (m_carbon_state) {
					case 0:
						cishu = "" + m_carbon_copy.getM_vim();
						break;
					case 1:
						cishu = "<mark c=FC8800>" + m_carbon_copy.getM_vim() + "</mark>";

						break;
					case 2:
						cishu = "<mark c=CD2626>" + m_carbon_copy.getM_vim() + "</mark>";
						break;

					default:
						break;
				}
				m_carbon_but[i].setName("进入");
				m_carbon_but[i].setBackground(m_cr_but, false);
				m_carbon_but[i].setTouch(true);
				m_textbox[i].setText("   " + m_carbon_copy.getName() + " " + "("
						+ m_carbon_copy.getLv() + ")"
						+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "精力："
						+ cishu
						+ "/" + "次" + DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "状态："
						+ m_carbon_copy.STATUS_DESCRIBE[m_carbon_copy.getStatus()]);
			}
			else if (m_carbon_copy.getStatus() == m_carbon_copy.STATUS_LINE_UP) {
				String cishu = "" + m_carbon_copy.getM_vim();
				switch (m_carbon_state) {
					case 0:
						cishu = "" + m_carbon_copy.getM_vim();
						break;
					case 1:
						cishu = "<mark c=FC8800>" + m_carbon_copy.getM_vim() + "</mark>";

						break;
					case 2:
						cishu = "<mark c=CD2626>" + m_carbon_copy.getM_vim() + "</mark>";
						break;

					default:
						break;
				}
				m_carbon_but[i].setName("取消排队");
				m_carbon_but[i].setBackground(m_cr_but, false);
				m_carbon_but[i].setTouch(true);
				m_textbox[i].setText("   " + m_carbon_copy.getName() + " " + "("
						+ m_carbon_copy.getLv() + ")"
						+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "精力："
						+ cishu
						+ "/" + "次" + DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "状态："
						+ m_carbon_copy.STATUS_DESCRIBE[m_carbon_copy.getStatus()]);

			}
			else if (m_carbon_copy.getStatus() == m_carbon_copy.STATUS_ADD) {
				String cishu = "" + m_carbon_copy.getM_vim();
				switch (m_carbon_state) {
					case 0:
						cishu = "" + m_carbon_copy.getM_vim();
						break;
					case 1:
						cishu = "<mark c=FC8800>" + m_carbon_copy.getM_vim() + "</mark>";

						break;
					case 2:
						cishu = "<mark c=CD2626>" + m_carbon_copy.getM_vim() + "</mark>";
						break;

					default:
						break;
				}
				m_carbon_but[i].setName("增加次数");
				m_carbon_but[i].setBackground(m_cr_but, false);
				m_carbon_but[i].setTouch(true);
				m_textbox[i].setText("   " + m_carbon_copy.getName() + " " + "("
						+ m_carbon_copy.getLv() + ")"
						+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "精力："
						+ cishu
						+ "/" + "次" + DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "状态："
						+ m_carbon_copy.STATUS_DESCRIBE[m_carbon_copy.getStatus()]);

			}
			else if (m_carbon_copy.getStatus() == m_carbon_copy.STATUS_NO_INTO) {
				String cishu = "" + m_carbon_copy.getM_vim();
				switch (m_carbon_state) {
					case 0:
						cishu = "" + m_carbon_copy.getM_vim();
						break;
					case 1:
						cishu = "<mark c=FC8800>" + m_carbon_copy.getM_vim() + "</mark>";

						break;
					case 2:
						cishu = "<mark c=CD2626>" + m_carbon_copy.getM_vim() + "</mark>";
						break;

					default:
						break;
				}
				m_carbon_but[i].setName("不可进入");
				m_carbon_but[i].setBackground(m_cr_but_1, false);
				m_carbon_but[i].setTouch(false);
				m_textbox[i].setText("   " + m_carbon_copy.getName() + " " + "("
						+ m_carbon_copy.getLv() + ")"
						+ DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "精力："
						+ cishu
						+ "/" + "次" + DWControlTools.CHANGE_ROW + DWControlTools.CHANGE_ROW + "   " + "状态："
						+ m_carbon_copy.STATUS_DESCRIBE[m_carbon_copy.getStatus()]);
			}
		}
	}

	/**
	 * 副本通关发放奖励界面 给出三个箱子让玩家选择的界面
	 * @throws IOException
	 */
	String GameCarbonName; //副本名字
	String GameCarbonKey; //副本的key
	int GameCarbonTime; //副本通关时间
	int GameCarbonExp; //奖励经验
	int GameCarbonMoney; //奖励钱
	String GameCarbonBox1; //第1个箱子的描述
	int GameCarbonBox2_money; //第2个箱子 开启所用金币
	String GameCarbonBox2; //第2个箱子的描述
	int GameCarbonBox3_money; //第3个箱子 开启所用元宝
	String GameCarbonBox3; //第3个箱子的描述
	private Bitmap m_shuzi_img;

	public void recvGameCarbonOverReward(DataInputStream dis) throws IOException
	{
		GameCarbonName = dis.readUTF(); //副本名字
		GameCarbonKey = dis.readUTF(); //副本的key
		GameCarbonTime = dis.readInt(); //副本通关时间
		GameCarbonExp = dis.readInt(); //奖励经验
		GameCarbonMoney = dis.readInt(); //奖励钱
		GameCarbonBox1 = dis.readUTF(); //第1个箱子的描述
		GameCarbonBox2_money = dis.readInt(); //第2个箱子 开启所用金币
		GameCarbonBox2 = dis.readUTF(); //第2个箱子的描述
		GameCarbonBox3_money = dis.readInt(); //第3个箱子 开启所用元宝
		GameCarbonBox3 = dis.readUTF(); //第3个箱子的描述
		if (DWControlsManager.getInstance().contains(UIWindows.getInstance().m_map.m_world_map))
		{
			DWControlsManager.getInstance().removeControl(UIWindows.getInstance().m_map.m_world_map);
		}
		if (DWControlsManager.getInstance().contains(UIWindows.getInstance().m_hook.m_hook_frame))
		{
			DWControlsManager.getInstance().removeControl(UIWindows.getInstance().m_hook.m_hook_frame);
		}
		open((byte) 2);
	}

	/**
	 * 副本通关 开宝箱后得到的奖励 开宝箱发送sendGameCarbonOpenBox
	 * @throws IOException
	 */
	DWFrame m_box_frame = null;
	DWImageBox m_ima[];
	Item[] items;

	public void recvGameCarbonOpenBox(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		byte box_index = dis.readByte(); //第几个宝箱
		byte state = dis.readByte(); //0　失败，1 成功　，2　金钱不足
		switch (state) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "开启宝箱失败。");
				break;
			case 1:
				byte size = dis.readByte(); //得到宝物数量
				items = new Item[size];
				for (int i = 0; i < size; i++) {
					Item item = new Item();
					item.m_key = dis.readUTF(); //宝物key
					item.m_name = dis.readUTF(); //宝物名字
					item.m_iconId = dis.readShort(); //宝物图标id
					item.m_num = dis.readInt();///宝物的数量
					item.m_quality = dis.readByte();//道具品质
					items[i] = item;
				}
				if (box_index == 1) {
					m_box_1.setImage(m_dh[0][4]);
					m_flag_1 = false;
					m_xz[0] = false;
				}
				else if (box_index == 2) {
					m_box_2.setImage(m_dh[1][4]);
					m_flag_2 = false;
					m_xz[1] = false;
				}
				else if (box_index == 3) {
					m_box_3.setImage(m_dh[2][4]);
					m_flag_3 = false;
					m_xz[2] = false;
				}

				if (m_box_frame != null) {
					DWControlsManager.getInstance().removeControl(m_box_frame);
				}
				m_box_frame = new DWFrame(400, 250);
				m_box_frame.setTouchZoomIn(0, 0);
				DWControlsManager.getInstance().addControl(m_box_frame);

				DWListbox m_listbox_xq = new DWListbox(m_box_frame.getShowWidth() - 40,
						m_box_frame.getShowHeight() - 30);
				m_listbox_xq.setNearAnchor(m_box_frame, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
				m_listbox_xq.setLineSpacing(10);
				m_box_frame.addControl(m_listbox_xq);

				m_ima = new DWImageBox[size];
				for (int i = 0; i < size; i++) {
					IconManger m_icon = new IconManger();
					DWListSubItem m_lsi = new DWListSubItem();
					m_ima[i] = new DWImageBox(m_icon.getIcon(items[i].m_iconId));
					DWImageBox m_ima_1 = new DWImageBox(m_cr_grid_ima);
					m_ima_1.setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_ima[i].setNearAnchor(m_lsi, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					final int m_index_ima = i;
					m_ima[i].addListener(new DWListener() {

						public void OnDoubleClick()
						{
						}

						public void OnClick()
						{
							Chakan(m_index_ima);
						}
					});
					DWTextbox m_textbox = new DWTextbox("<mark c=" + getcolor(items[i].m_quality) + ">"
							+ items[i].m_name + "</mark>" + "×" + items[i].m_num, m_listbox_xq
							.getShowWidth()
							- 30 - m_ima[i].getShowWidth());
					m_textbox.setNearAnchor(m_ima[i], Tools.LEFT_BOTTOM, Tools.RIGHT_BOTTOM, 30, 0);

					m_lsi.addControls(m_ima[i]);
					m_lsi.addControls(m_textbox);
					m_listbox_xq.addSubItem(m_lsi);
				}
//				if(m_flag_4 == false)
//				{
//					DWControlsManager.getInstance().removeControl(m_win_frame);
//					DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
//					m_flag_4 = true;
//				}
				break;
			case 2: //金钱不足
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您的金钱不足。");
				break;
		}
	}

	public void Chakan(int i)
	{
		m_ima[i].setSelect(true);
		DWGameManager.getInstance().getSendMessage().sendSeeItemInfos(0, items[i].m_key);
	}

	/**
	 * 购买精力
	 * @param dis
	 * @throws IOException
	 */
	public void recvGameCarbonGVim(DataInputStream dis) throws IOException
	{
		DWGameManager.getInstance().getSendMessage().unlockNetwork(GameMessage.锁_副本);
		byte state = dis.readByte();//状态；1成功，0 失败，2 元宝不足

		switch (state) {
			case 0:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "购买失败。");
				break;
			case 1:
				Update_data();
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "恭喜您，购买精力成功。");
				break;
			case 2:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉，元宝不足。");
				break;
			case 3:
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "抱歉，非VIP不得购买。");
				break;
		}
	}

	public void GameCarbonWindow()
	{
		if (m_fuben_frame != null) {
			DWControlsManager.getInstance().removeControl(m_fuben_frame);
		}
		//////画布
		m_fuben_frame = new DWFrame(DWFrame.FRAME_TYPE_FULL, true);
		m_fuben_frame.setClickClose(false);
		m_fuben_frame.setThrough(true);

		/////标题
		m_fuben_tit = new DWTitle("", m_fuben_frame);
		m_tit_ima = new DWImageBox(m_cr_tit);
		m_tit_ima.setNearAnchor(m_fuben_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		///退出按钮
		m_tuichu_ima = new DWImageBox(m_cr_tc);
		m_tuichu_ima.setNearAnchorUn(m_fuben_tit, Tools.RIGHT_VCENTER,
				Tools.RIGHT_VCENTER, 0, 0);
		m_tuichu_ima.addListener(m_tuichu_lis);
		m_tuichu_ima.setTouchZoomIn(40, 40);

		/////下面的一条
		m_xiamian_bg = new DWBackground(m_cr_down, m_fuben_frame.getShowWidth() - 60,
				m_cr_but.getHeight() + 6);

		//////小背景
		m_xbj_bg = new DWBackground(
				m_fuben_frame.getShowWidth() - 40,
				m_fuben_frame.getShowHeight() - (m_fuben_tit.getShowHeight() - 20) - 10 - m_xiamian_bg.getShowHeight()
						- 10);

		m_xbj_bg.setNearAnchor(m_fuben_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 20,
				10 + (m_fuben_tit.getShowHeight() - 20));

		m_xiamian_bg.setNearAnchor(m_xbj_bg, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 10, 0);

		//////listbox
		m_listbox = new DWListbox(m_xbj_bg.getShowWidth() - 20, m_xbj_bg.getShowHeight() - 20);
		m_listbox.setNearAnchor(m_xbj_bg, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10);
		m_listbox.setLineSpacing(10);
		m_listbox.setShowBackgroundRect(false);
		if (m_listbox != null) {
			m_listbox.removeAllSubItem();
		}

		Tools.debugPrintln("副本长度：" + DWGameManager.getInstance().m_role.m_game_carbon.size());
		if (DWGameManager.getInstance().m_role.m_game_carbon != null
				&& DWGameManager.getInstance().m_role.m_game_carbon.size() != 0) {
			m_textbox = new DWTextbox[DWGameManager.getInstance().m_role.m_game_carbon.size()];
			m_carbon_but = new DWButton[DWGameManager.getInstance().m_role.m_game_carbon.size()];
			m_xxbj_bg = new DWBackground[DWGameManager.getInstance().m_role.m_game_carbon.size()];

			/////当前精力标签
			m_jl_tb = new DWTextbox("当前精力：");
			DWLabel m_l = new DWLabel("当前精力：");
			m_jl_tb.setShowWideHigh(m_xiamian_bg.getShowWidth() / 3,
					m_xiamian_bg.getShowHeight() - 20);
			m_jl_tb.setNearAnchor(m_xiamian_bg, Tools.LEFT_TOP, Tools.LEFT_TOP, 10, 10);

			/////当前精力的textbox
			m_jingli_textbox = new DWTextbox(Integer.toString(DWGameManager.getInstance().m_role.m_jinglizhi_shengyu));
			Tools.debugPrintln("剩余精力：" + DWGameManager.getInstance().m_role.m_jinglizhi_shengyu);
			m_jingli_textbox.setNearAnchor(m_jl_tb, Tools.LEFT_TOP, Tools.LEFT_TOP, m_l.getShowWidth(), 0);

			m_shuzi = new DWImageBox(100, 50);
			m_shuzi.setNearAnchor(m_jl_tb, Tools.LEFT_TOP, Tools.LEFT_TOP, m_l.getShowWidth(), (m_l.getShowHeight()
					- m_shuzi_img.getHeight() >> 1) + 3);
			m_shuzi.addExternalDraw(new DWExternalDraw() {
				public void externalDraw(DWGraphics g, int x, int y)
				{

					Tools.drawNumber(g, m_shuzi_img, x, y, m_shuzi_img.getWidth() / 10,
							m_shuzi_img.getHeight(), 1, 1, DWGameManager.getInstance().m_role.m_jinglizhi_shengyu, 1,
							Tools.LEFT_TOP, false);

				}
			});

			for (int m_carbon_count = 0; m_carbon_count < DWGameManager.getInstance().m_role.m_game_carbon.size(); m_carbon_count++) {

				///小小背景
				m_xxbj_bg[m_carbon_count] = new DWBackground(m_cr_xxbj, (m_listbox.getShowWidth() - 30) / 2,
						(m_listbox.getShowHeight() - 10) / 2);
				///创建一个副本的对象，得到副本的信息
				GameCarbon m_carbon = DWGameManager.getInstance().m_role.m_game_carbon.get(m_carbon_count);

				String cishu = "" + m_carbon.getM_vim();
				switch (m_carbon_state) {
					case 0:
						if (m_carbon.getDifficulty() == 0) {
							cishu = "" + m_carbon.getM_vim();
							m_textbox[m_carbon_count] = new DWTextbox("   " + m_carbon.getName() + " "
									+ "("
									+ m_carbon.getLv() + "级)" + DWControlTools.CHANGE_ROW + " "
									+ DWControlTools.CHANGE_ROW + "   "
									+ "精力："
									+ cishu + "点/" + "次"
									+ "   "
									+ m_carbon.STATUS_DESCRIBE[m_carbon.getStatus()],
									m_xxbj_bg[m_carbon_count].getShowWidth() - 40, m_xxbj_bg[m_carbon_count]
											.getShowHeight() - 14);
							m_textbox[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.LEFT_TOP,
									Tools.LEFT_TOP, 15, 7);
						}
						else if (m_carbon.getDifficulty() == 1) {
							cishu = "" + m_carbon.getM_vim();
							m_textbox[m_carbon_count] = new DWTextbox("   " + m_carbon.getName() + " "
									+ "("
									+ m_carbon.getLv() + "级)"
									+ DWControlTools.CHANGE_ROW + "   "
									+ "精力："
									+ cishu + "点/" + "次"
									+ "   "
									+ m_carbon.STATUS_DESCRIBE[m_carbon.getStatus()]
									+ DWControlTools.CHANGE_ROW
									+ "   " + "<mark c=FFBB11>通关该副本可获得10点帮会成长值和2点帮贡</mark>",
									m_xxbj_bg[m_carbon_count].getShowWidth() - 40, m_xxbj_bg[m_carbon_count]
											.getShowHeight() - 14);
							m_textbox[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.LEFT_TOP,
									Tools.LEFT_TOP, 15, 7);
						}
						break;
					case 1:
						if (m_carbon.getDifficulty() == 0) {
							cishu = "<mark c=FC8800>" + m_carbon.getM_vim() + "</mark>";
							m_textbox[m_carbon_count] = new DWTextbox("   " + m_carbon.getName() + " "
									+ "("
									+ m_carbon.getLv() + "级)" + DWControlTools.CHANGE_ROW + " "
									+ DWControlTools.CHANGE_ROW
									+ "   "
									+ "精力："
									+ cishu + "点/" + "次"
									+ "   "
									+ m_carbon.STATUS_DESCRIBE[m_carbon.getStatus()],
									m_xxbj_bg[m_carbon_count].getShowWidth() - 40, m_xxbj_bg[m_carbon_count]
											.getShowHeight() - 14);
							m_textbox[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.LEFT_TOP,
									Tools.LEFT_TOP, 15, 7);
						}
						else if (m_carbon.getDifficulty() == 1) {
							cishu = "<mark c=FC8800>" + m_carbon.getM_vim() + "</mark>";
							m_textbox[m_carbon_count] = new DWTextbox("   " + m_carbon.getName() + " "
									+ "("
									+ m_carbon.getLv() + "级)" + DWControlTools.CHANGE_ROW
									+ "   "
									+ "精力："
									+ cishu + "点/" + "次"
									+ "   "
									+ m_carbon.STATUS_DESCRIBE[m_carbon.getStatus()]
									+ DWControlTools.CHANGE_ROW + " "
									+ "   " + "<mark c=FFBB11>通关该副本可获得10点帮会成长值和2点帮贡</mark>",
									m_xxbj_bg[m_carbon_count].getShowWidth() - 40, m_xxbj_bg[m_carbon_count]
											.getShowHeight() - 14);
							m_textbox[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.LEFT_TOP,
									Tools.LEFT_TOP, 15, 7);
						}
						break;
					case 2:
						if (m_carbon.getDifficulty() == 0) {
							cishu = "<mark c=CD2626>" + m_carbon.getM_vim() + "</mark>";
							m_textbox[m_carbon_count] = new DWTextbox("   " + m_carbon.getName() + " "
									+ "("
									+ m_carbon.getLv() + "级)" + DWControlTools.CHANGE_ROW + " "
									+ DWControlTools.CHANGE_ROW
									+ "   "
									+ "精力："
									+ cishu + "点/" + "次"
									+ "   "
									+ m_carbon.STATUS_DESCRIBE[m_carbon.getStatus()],
									m_xxbj_bg[m_carbon_count].getShowWidth() - 40, m_xxbj_bg[m_carbon_count]
											.getShowHeight() - 14);
							m_textbox[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.LEFT_TOP,
									Tools.LEFT_TOP, 15, 7);
						}
						else if (m_carbon.getDifficulty() == 1) {
							cishu = "<mark c=CD2626>" + m_carbon.getM_vim() + "</mark>";
							m_textbox[m_carbon_count] = new DWTextbox("   " + m_carbon.getName() + " "
									+ "("
									+ m_carbon.getLv() + "级)"
									+ DWControlTools.CHANGE_ROW
									+ "   "
									+ "精力："
									+ cishu + "点/" + "次"
									+ "   "
									+ m_carbon.STATUS_DESCRIBE[m_carbon.getStatus()]
									+ DWControlTools.CHANGE_ROW
									+ "   " + "<mark c=FFBB11>通关该副本可获得10点帮会成长值和2点帮贡</mark>",
									m_xxbj_bg[m_carbon_count].getShowWidth() - 40, m_xxbj_bg[m_carbon_count]
											.getShowHeight() - 14);
							m_textbox[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.LEFT_TOP,
									Tools.LEFT_TOP, 15, 7);
						}
						break;

					default:
						break;
				}
				if (m_textbox[m_carbon_count] == null) {
					Tools.debugPrintln("副本m_textbox文本空指针869+状态：" + m_carbon_state);
					return;
				}
				///关于每个副本的按钮布局
				if (m_carbon.getStatus() == m_carbon.STATUS_JOIN) {
					////进入按钮
					m_carbon_but[m_carbon_count] = new DWButton("进入", m_cr_but);
					m_carbon_but[m_carbon_count].setDownImage(m_cr_but_1);
					m_carbon_but[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.RIGHT_BOTTOM,
							Tools.RIGHT_BOTTOM, -5, -5);

				}
				else if (m_carbon.getStatus() == m_carbon.STATUS_LINE_UP) {
					////取消排队按钮
					m_carbon_but[m_carbon_count] = new DWButton("取消排队", m_cr_but);
					m_carbon_but[m_carbon_count].setDownImage(m_cr_but_1);
					m_carbon_but[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.RIGHT_BOTTOM,
							Tools.RIGHT_BOTTOM, -5, -5);

				}
				else if (m_carbon.getStatus() == m_carbon.STATUS_ADD) {
					////增次按钮
					m_carbon_but[m_carbon_count] = new DWButton("增加次数", m_cr_but);
					m_carbon_but[m_carbon_count].setDownImage(m_cr_but_1);
					m_carbon_but[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.RIGHT_BOTTOM,
							Tools.RIGHT_BOTTOM, -5, -5);
				}

				else if (m_carbon.getStatus() == m_carbon.STATUS_NO_INTO) {
					////不可进入按钮
					m_carbon_but[m_carbon_count] = new DWButton("不可进入", m_cr_but_1);
					m_carbon_but[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count], Tools.RIGHT_BOTTOM,
							Tools.RIGHT_BOTTOM, -5, -5);
				}
				if (m_carbon_count % 2 == 0) {
					m_lsi_1 = new DWListSubItem();

					m_xxbj_bg[m_carbon_count].setNearAnchor(m_lsi_1, Tools.LEFT_TOP, Tools.LEFT_TOP, 0, 0);
					m_lsi_1.addControls(m_xxbj_bg[m_carbon_count]);
					m_lsi_1.addControls(m_textbox[m_carbon_count]);
					m_lsi_1.addControls(m_carbon_but[m_carbon_count]);
					if (m_carbon_count == DWGameManager.getInstance().m_role.m_game_carbon.size() - 1) {
						m_listbox.addSubItem(m_lsi_1);
					}
				}
				else {
					m_xxbj_bg[m_carbon_count].setNearAnchor(m_xxbj_bg[m_carbon_count - 1], Tools.LEFT_TOP,
							Tools.RIGHT_TOP, 30, 0);
					m_lsi_1.addControls(m_xxbj_bg[m_carbon_count]);
					m_lsi_1.addControls(m_textbox[m_carbon_count]);
					m_lsi_1.addControls(m_carbon_but[m_carbon_count]);
					m_listbox.addSubItem(m_lsi_1);
				}

				final int m_gamecarbon_index_1 = m_carbon_count;///得到的是第几个副本里面的按钮

				m_carbon_but[m_carbon_count].addListener(new DWListener() {

					public void OnDoubleClick()
					{

					}

					public void OnClick()
					{
						Tools.debugPrintln("m_gamecarbon_index_1" + m_gamecarbon_index_1);
						UIHook.closeHook();
						m_gcb = DWGameManager.getInstance().m_role.m_game_carbon.get(m_gamecarbon_index_1);
						if (m_gcb.getStatus() == m_gcb.STATUS_JOIN) {
							if (m_gcb.getLv() > DWGameManager.getInstance().m_role.m_lv)
							{
								DWGameManager.getInstance().showToast("对不起，您的等级不够进入此副本，继续加油！", 1000);
							}
							else
							{
								if (m_gcb.getM_vim() > DWGameManager.getInstance().m_role.m_jinglizhi_shengyu)//Integer.parseInt(m_jingli_textbox.getText()))
								{
									DWGameManager.getInstance().getSendMessage().sendGameCarbonBuy();
								}
								else
								{
									gameCarbonJoin(m_gcb.getKey());
								}
							}
						}
						else if (m_gcb.getStatus() == m_gcb.STATUS_LINE_UP) {
							gameCarbonLineUp(m_gcb.getKey());
						}
					}
				});
				/**
				 * 点击掉落详情
				 */
				m_textbox[m_carbon_count].addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						m_gcb_1 = DWGameManager.getInstance().m_role.m_game_carbon.get(m_gamecarbon_index_1);
						m_xxbj_bg[m_gamecarbon_index_1].setBackground(m_cr_xxbj_xz);
						GameCarbonRewardDetails(m_gcb_1.getKey());
					}
				});
			}
		}

		////购买精力按钮
		m_goumai_but = new DWButton("", m_cr_buy);
		m_goumai_but.setDownImage(m_cr_buy_1);
		m_goumai_but.setNearAnchor(m_xiamian_bg, Tools.RIGHT_BOTTOM, Tools.RIGHT_BOTTOM, -10, -3);
		m_goumai_but.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				//Integer.parseInt(UIWindows.getInstance().m_fuben.m_jingli_textbox.getText())
				if (DWGameManager.getInstance().m_role.m_jinglizhi_shengyu >= DWGameManager
						.getInstance().m_role.m_jinglizhi_zonggong)
				{
					DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "您现在精力已满，不能购买。");
				}
				else
				{
					DWGameManager.getInstance().getSendMessage().sendGameCarbonBuy();
				}
			}
		});

		m_goumai_text = new DWTextbox("购买精力");
		m_goumai_text.setNearAnchor(m_goumai_but, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER);
		m_goumai_text.setTouch(false);

		/////查看掉落详情的textbox
		DWTextbox m_textbox_xiamian = new DWTextbox("     点击副本查看掉落详情", m_xiamian_bg.getShowWidth() / 3, m_xiamian_bg
				.getShowHeight() - 20);
		m_textbox_xiamian.setNearAnchor(m_jl_tb, Tools.LEFT_TOP, Tools.RIGHT_TOP, 0,
				0);

		m_fuben_frame.addControl(m_shuzi);
		m_fuben_frame.addControl(m_fuben_tit);
		m_fuben_frame.addControl(m_tit_ima);
		m_fuben_frame.addControl(m_tuichu_ima);
		m_fuben_frame.addControl(m_xbj_bg);
		m_fuben_frame.addControl(m_listbox);
		m_fuben_frame.addControl(m_xiamian_bg);
		m_fuben_frame.addControl(m_goumai_but);
		m_fuben_frame.addControl(m_goumai_text);
		m_fuben_frame.addControl(m_jl_tb);
//		m_fuben_frame.addControl(m_jingli_textbox);
		m_fuben_frame.addControl(m_shuzi);
		m_fuben_frame.addControl(m_textbox_xiamian);
		DWControlsManager.getInstance().addControl(m_fuben_frame);
	}

	private DWListener m_tuichu_lis = new DWListener() {

		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			DWControlsManager.getInstance().removeControl(m_fuben_frame);
		}
	};

	public void init()
	{
		// 加载图片
		m_cr_tit = UIWindows.createImage("/img/newui/fuben_1.gnp");
		m_cr_tit_ima = UIWindows.createImage("/img/newui/fubendiaoluo_1.gnp");
		m_cr_xxbj = UIWindows.createImage("/img/newui/beibaobj_1.gnp");///每个副本的小背景
		m_cr_xxbj_xz = UIWindows.createImage("/img/newui/xiaobeijing_1.gnp");
		m_cr_but = UIWindows.createImage("/img/newui/anniu_6.gnp"); ////按钮的图片
		m_cr_but_1 = UIWindows.createImage("/img/newui/anniu_6ax.gnp"); ////按钮点击后变的图片
		m_cr_tongguan_tit = UIWindows.createImage("/img/newui/fubentongguan_1.gnp");
		m_cr_buy = UIWindows.createImage("/img/newui/anniu_6.gnp"); ////按钮的图片
		m_cr_buy_1 = UIWindows.createImage("/img/newui/anniu_6ax.gnp"); ////按钮点击后变的图片
		m_cr_tc = UIWindows.createImage("/img/newui/fanhuianniu_1.gnp"); // 退出叉键按钮的图片
		m_cr_down = UIWindows.createImage("/img/newui/zhujiemianltk_1.gnp");
		m_cr_win = UIWindows.createImage("/img/newui/fubensl_1.gnp");
		m_cr_grid_ima = UIWindows.createImage("/img/newui/wupinlan.gnp");

		m_dh[0][0] = UIWindows.createImage("/img/newui/fubentxz_1.gnp");
		m_dh[0][1] = UIWindows.createImage("/img/newui/fubentxz_2.gnp");
		m_dh[0][2] = UIWindows.createImage("/img/newui/fubentxz_3.gnp");
		m_dh[0][3] = UIWindows.createImage("/img/newui/fubentxz_4.gnp");
		m_dh[1][0] = UIWindows.createImage("/img/newui/fubenyxz_1.gnp");
		m_dh[1][1] = UIWindows.createImage("/img/newui/fubenyxz_2.gnp");
		m_dh[1][2] = UIWindows.createImage("/img/newui/fubenyxz_3.gnp");
		m_dh[1][3] = UIWindows.createImage("/img/newui/fubenyxz_4.gnp");
		m_dh[2][0] = UIWindows.createImage("/img/newui/fubenjxz_1.gnp");
		m_dh[2][1] = UIWindows.createImage("/img/newui/fubenjxz_2.gnp");
		m_dh[2][2] = UIWindows.createImage("/img/newui/fubenjxz_3.gnp");
		m_dh[2][3] = UIWindows.createImage("/img/newui/fubenjxz_4.gnp");
		m_dh[0][4] = UIWindows.createImage("/img/newui/fubentxzdk_1.gnp");
		m_dh[1][4] = UIWindows.createImage("/img/newui/fubenyxzdk_1.gnp");
		m_dh[2][4] = UIWindows.createImage("/img/newui/fubenjxzdk_1.gnp");

		m_shuzi_img = UIWindows.createImage("/img/newui/shuzi_7.gnp");
	}

	public void open(byte index)
	{
		// 开启窗口
		switch (index) {
			case 0:
				GameCarbonWindow();
				break;
			case 1:
				List();
				break;
			case 2:
				GameCarbonWin();
				break;
			case 3:
				Update_data();
				break;
		}

	}

	public void close(byte index)
	{
		// 关闭窗口
	}

	public void dispose()
	{
		// 销毁图片

	}

	Bitmap m_dh[][] = new Bitmap[3][5];
	private final int m_arc1_all = 4;
	private final int m_arc1_speed = 2;
	private int m_timer = 0;;
	private int time = 0;

	public void logic()
	{
		int way = (m_timer % (m_arc1_all * m_arc1_speed)) / m_arc1_speed;
		if (DWControlsManager.getInstance().contains(m_win_frame)) {
			if (m_win_frame != null) {
				if (m_xz[0]) {
					m_box_1.setImage(m_dh[0][way]);
				}
				else {
					m_box_1.setImage(m_dh[0][4]);
				}
				if (m_xz[1]) {
					m_box_2.setImage(m_dh[1][way]);
				}
				else {
					m_box_2.setImage(m_dh[1][4]);
				}
				if (m_xz[2]) {
					m_box_3.setImage(m_dh[2][way]);
				}
				else {
					m_box_3.setImage(m_dh[2][4]);
				}
			}
		}
		if (m_jl_tb != null) {
			if (DWGameManager.getInstance().m_role.m_jinglizhi_shengyu <= 20) {
				time++;
				if (time < 5) {
					m_goumai_text.setText("<mark c=FF0000>购买精力</mark>");
				}
				else if (time < 10) {
					m_goumai_text.setText("购买精力");
				}
				else {
					time = 0;
				}
			}
		}
		if (++m_timer > 1000000) {
			m_timer = 0;
		}
	}

	public void List()
	{
//		final DWMessageBox m_mb = new DWMessageBox("温馨提示", "您已成功参加了" + m_gcb.getName() +
//				"的自动组队,组队成功时将被自动传入副本。", null, "确定");
		final DWMessageBox m_mb = new DWMessageBox("温馨提示", info, null, "确定");
		m_mb.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK)
				{
					DWControlsManager.getInstance().removeControl(m_mb);
					DWControlsManager.getInstance().removeControl(m_fuben_frame);
					DWGameManager.getInstance().getSendMessage().sendGameCarbonOpen();
				}
			}
		});
		DWControlsManager.getInstance().addControl(m_mb);
	}

	private void gameCarbonJoin(final String key)
	{
		m_carbon_pm = new DWPopMenu(new String[] { "自动组队", "进入副本" }, m_cr_buy);
		m_carbon_pm.setDownImage(m_cr_buy_1);
		m_carbon_pm.addListener(new DWListener() {

			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				int m_index = m_carbon_pm.getIndex();
				if (m_index == 0) {
					DWGameManager.getInstance().getSendMessage().sendGameCarbonAuto(key);

				}
				else if (m_index == 1) {
					DWGameManager.getInstance().getSendMessage().sendGameCarbonCheck(key);
				}
				DWControlsManager.getInstance().removeControl(m_carbon_pm);
			}
		});
		DWControlsManager.getInstance().addControl(m_carbon_pm);
	}

	private void gameCarbonAdd(final String key)
	{
		final DWMessageBox mb = new DWMessageBox("温馨提示", "额外进入副本需要消耗一张[秘境地图],是否增次?",
				"确定", "返回");
		mb.addListener(new DWListener() {
			public void OnDoubleClick()
			{
			}

			public void OnClick()
			{
				if (mb.getResult() == DWMessageBox.SOFTKEY_OK) {
					DWGameManager.getInstance().getSendMessage().sendGameCarbonAdd(key);
				}
				DWControlsManager.getInstance().removeControl(mb);
			}
		});
		DWControlsManager.getInstance().addControl(mb);
	}

	private void gameCarbonLineUp(final String key)
	{
		final DWMessageBox m_mb = new DWMessageBox("温馨提示", "确定取消排队？", "确定", "返回");
		m_mb.addListener(new DWListener() {

			public void OnDoubleClick()
			{

			}

			public void OnClick()
			{
				if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
					DWControlsManager.getInstance().removeControl(m_mb);
					DWGameManager.getInstance().getSendMessage().sendGameCarbonExit(key);
					DWControlsManager.getInstance().removeControl(m_fuben_frame);
					DWGameManager.getInstance().getSendMessage().sendGameCarbonOpen();
				}
				else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
					DWControlsManager.getInstance().removeControl(m_mb);
				}
			}
		});
		DWControlsManager.getInstance().addControl(m_mb);
	}

	DWFrame m_win_frame = null;
	DWTitle m_win_tit;
	DWBackground m_win_xbj_up_bg;
	DWBackground m_win_xbj_down_bg;
	DWImageBox m_box_1;
	DWImageBox m_box_2;
	DWImageBox m_box_3;
	DWImageBox m_win_ima;
	Bitmap m_cr_win = null;
	DWImageBox m_tc_ima;

	DWLabel m_box_text_1;
	DWLabel m_box_text_2;
	DWLabel m_box_text_3;
	DWLabel m_box_1_text;
	DWLabel m_box_2_text;
	DWLabel m_box_3_text;
	Boolean m_flag_1 = true;
	Boolean m_flag_2 = true;
	Boolean m_flag_3 = true;
	Boolean m_xz[] = { true, true, true };

	public void GameCarbonWin()
	{
		if (m_win_frame != null) {
			DWControlsManager.getInstance().removeControl(m_win_frame);
		}
		m_flag_1 = true;
		m_flag_2 = true;
		m_flag_3 = true;
		m_xz[0] = true;
		m_xz[1] = true;
		m_xz[2] = true;
		////画布
		m_win_frame = new DWFrame(DWFrame.FRAME_TYPE_HALF_HCENTER, true);
		m_win_frame.setClickClose(false);
		m_win_frame.setThrough(true);

		//标题
		m_win_tit = new DWTitle("", m_win_frame);
		m_win_frame.addControl(m_win_tit);
		m_tit_ima_tongguan = new DWImageBox(m_cr_tongguan_tit);
		m_tit_ima_tongguan.setNearAnchor(m_win_tit, Tools.HCENTER_VCENTER, Tools.HCENTER_VCENTER, 0, 0);
		m_win_frame.addControl(m_tit_ima_tongguan);
		///退出按钮
		m_tc_ima = new DWImageBox(m_cr_tc);
		m_tc_ima.setNearAnchorUn(m_win_tit, Tools.RIGHT_VCENTER,
				Tools.RIGHT_VCENTER, 0, 0);
		m_win_frame.addControl(m_tc_ima);
		m_tc_ima.addListener(m_tc_lis);
		m_tc_ima.setTouchZoomIn(40, 40);

		//上面的小背景
		m_win_xbj_up_bg = new DWBackground(m_win_frame.getShowWidth() - 20, m_cr_win.getHeight() + 20);
		m_win_xbj_up_bg.setNearAnchor(m_win_frame, Tools.LEFT_TOP, Tools.LEFT_TOP, 10,
				5 + (m_win_tit.getShowHeight() - 20));
		m_win_frame.addControl(m_win_xbj_up_bg);

		//下面的小背景
		m_win_xbj_down_bg = new DWBackground(m_win_xbj_up_bg.getShowWidth(), m_win_frame.getShowHeight()
				- (m_win_tit.getShowHeight() - 20) - m_win_xbj_up_bg.getShowHeight() - 5 - 5 - 5);
		m_win_xbj_down_bg.setNearAnchor(m_win_xbj_up_bg, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 5);
		m_win_frame.addControl(m_win_xbj_down_bg);

		//上面的textbox
		int m_win_time_1;
		int m_win_time_2;
		int m_win_time_3;
		m_win_time_1 = GameCarbonTime / 3600;
		m_win_time_2 = GameCarbonTime % 3600 / 60;
		m_win_time_3 = GameCarbonTime % 3600 % 60;
		DWTextbox m_win_name = new DWTextbox("<mark c=" + getcolor(ItemConstants.稀有度_橙) + ">" + GameCarbonName
				+ "</mark>" + DWControlTools.CHANGE_ROW +
				"完成时间：" + DWControlTools.CHANGE_ROW + "<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">" + m_win_time_1
				+ "</mark>" + "小时" +
				"<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">" + m_win_time_2 + "</mark>" + "分" +
				"<mark c=" + getcolor(ItemConstants.稀有度_蓝) + ">" + m_win_time_3 + "</mark>" + "秒"
				+ DWControlTools.CHANGE_ROW +
				"经验：" + "<mark c=" + getcolor(ItemConstants.稀有度_绿) + ">" + GameCarbonExp + "</mark>"
				+ DWControlTools.CHANGE_ROW +
				"金钱：" + "<mark c=" + getcolor(ItemConstants.稀有度_橙) + ">" + GameCarbonMoney + "金" + "</mark>",
				m_win_xbj_up_bg.getShowWidth() - 40, m_win_xbj_up_bg.getShowHeight() - 14);
		m_win_name.setNearAnchor(m_win_xbj_up_bg, Tools.LEFT_TOP, Tools.LEFT_TOP, 20, 7);
		m_win_frame.addControl(m_win_name);

		//胜利的图片
		m_win_ima = new DWImageBox(m_cr_win);
		m_win_ima.setNearAnchor(m_win_name, Tools.RIGHT_VCENTER, Tools.RIGHT_VCENTER, 0, 0);
		m_win_frame.addControl(m_win_ima);

		/////下面布局
		DWTextbox m_win_text = new DWTextbox("<mark c=" + getcolor(ItemConstants.稀有度_绿) + ">" + "请选择您的奖励：" + "</mark>");
		m_win_text.setNearAnchor(m_win_xbj_down_bg, Tools.LEFT_TOP, Tools.LEFT_TOP, 20, 10);
		m_win_frame.addControl(m_win_text);

		///第一个箱子的名字
		m_box_text_1 = new DWLabel("青铜宝箱");
		m_box_text_1.setBackgroundColor(Tools.ALPHA);
		m_box_text_1.setShowWideHigh(m_dh[0][4].getWidth(), m_box_text_1.getShowHeight());
		m_box_text_1.setNearAnchor(m_win_text, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 8);
		m_win_frame.addControl(m_box_text_1);

		///第二个箱子的名字
		m_box_text_2 = new DWLabel("白银宝箱");
		m_box_text_2.setBackgroundColor(Tools.ALPHA);
		m_box_text_2.setTextColor(0xFF999999);
		m_box_text_2.setShowWideHigh(m_dh[0][4].getWidth(), m_box_text_2.getShowHeight());
		m_box_text_2.setNearAnchor(m_box_text_1, Tools.LEFT_TOP, Tools.RIGHT_TOP, (m_win_xbj_down_bg.getShowWidth()
				- 20 - m_dh[0][4].getWidth() - m_dh[0][4].getWidth() - m_dh[0][4]
				.getWidth()) / 3, 0);
		m_win_frame.addControl(m_box_text_2);

		///第三个箱子的名字
		m_box_text_3 = new DWLabel("黄金宝箱");
		m_box_text_3.setBackgroundColor(Tools.ALPHA);
		m_box_text_3.setTextColor(0xFFFFBB11);
		m_box_text_3.setShowWideHigh(m_dh[0][4].getWidth(), m_box_text_3.getShowHeight());
		m_box_text_3.setNearAnchor(m_box_text_2, Tools.LEFT_TOP, Tools.RIGHT_TOP, (m_win_xbj_down_bg.getShowWidth()
				- 20 - m_dh[0][4].getWidth() - m_dh[0][4].getWidth() - m_dh[0][4]
				.getWidth()) / 3, 0);
		m_win_frame.addControl(m_box_text_3);

		///第一个箱子的图片
		m_box_1 = new DWImageBox(m_dh[0][4]);
		m_box_1.setNearAnchor(m_box_text_1, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 2);
		m_win_frame.addControl(m_box_1);
		Tools.debugPrintln("第一个箱子的高度：" + m_box_1.getShowHeight());

		///第二个箱子的图片
		m_box_2 = new DWImageBox(m_dh[0][4]);
		m_box_2.setNearAnchor(m_box_text_2, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 2);
		m_win_frame.addControl(m_box_2);
		Tools.debugPrintln("第二个箱子的高度：" + m_box_2.getShowHeight());

		///第三个箱子的图片
		m_box_3 = new DWImageBox(m_dh[0][4]);
		m_box_3.setNearAnchor(m_box_text_3, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 2);
		m_win_frame.addControl(m_box_3);
		Tools.debugPrintln("第三个箱子的高度：" + m_box_3.getShowHeight());

		////第一个箱子的描述
		m_box_1_text = new DWLabel(GameCarbonBox1);
		m_box_1_text.setShowWideHigh(m_dh[0][4].getWidth(), 3 * DWFont.getDefaultFont().getHeight());
		m_box_1_text.setBackgroundColor(Tools.ALPHA);
		m_box_1_text.setNearAnchor(m_box_1, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 2);
		m_win_frame.addControl(m_box_1_text);

		///第二个箱子的描述
		m_box_2_text = new DWLabel(GameCarbonBox2);
		m_box_2_text.setShowWideHigh(m_dh[0][4].getWidth(), 3 * DWFont.getDefaultFont().getHeight());
		m_box_2_text.setBackgroundColor(Tools.ALPHA);
		m_box_2_text.setTextColor(0xFF999999);
		m_box_2_text.setNearAnchor(m_box_2, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 2);
		m_win_frame.addControl(m_box_2_text);

		///第三个箱子的描述
		m_box_3_text = new DWLabel(GameCarbonBox3);
		m_box_3_text.setShowWideHigh(m_dh[0][4].getWidth(), 3 * DWFont.getDefaultFont().getHeight());
		m_box_3_text.setBackgroundColor(Tools.ALPHA);
		m_box_3_text.setTextColor(0xFFFFBB11);
		m_box_3_text.setNearAnchor(m_box_3, Tools.LEFT_TOP, Tools.LEFT_BOTTOM, 0, 2);
		m_win_frame.addControl(m_box_3_text);

		///三个箱子的监听
		m_box_1.addListener(m_box_1_lis);
		m_box_2.addListener(m_box_2_lis);
		m_box_3.addListener(m_box_3_lis);

		DWControlsManager.getInstance().addControl(m_win_frame);
	}

	boolean m_flag_4 = true;
	private DWListener m_tc_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{

			if (m_flag_1 == false && m_flag_2 == false && m_flag_3 == false) {
				final DWMessageBox m_mb = new DWMessageBox("温馨提示", "您确定退出副本？", "确定", "返回");
				m_mb.addListener(new DWListener() {
					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
//							if(DWControlsManager.getInstance().contains(UIWindows.getInstance().m_recharge.m_recharge_Frame))
//							{
//								final DWMessageBox m_mb = new DWMessageBox("温馨提示", "充值界面还未关闭，确定操作完毕，现在退出副本吗？", "确定", "取消");
//								DWControlsManager.getInstance().addControl(m_mb);
//								m_mb.addListener(new DWListener() {
//
//									public void OnDoubleClick(){}
//
//									public void OnClick()
//									{
//										if(m_mb.getResult() == DWMessageBox.SOFTKEY_OK)
//										{
//											DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
//										}
//										else{}
//										DWControlsManager.getInstance().removeControl(m_mb);
//									}
//								});
//							}
//							else
//							{
//								DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
//							}
							DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
							DWControlsManager.getInstance().removeControl(m_mb);
						}
						else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
							DWControlsManager.getInstance().removeControl(m_mb);
						}
					}
				});
				DWControlsManager.getInstance().addControl(m_mb);
			}

			if (m_flag_1 == true || m_flag_2 == true || m_flag_3 == true) {
				final DWMessageBox m_mb = new DWMessageBox("温馨提示", "通关副本奖励还有宝箱未开启，您确定退出？", "确定", "返回");
				m_mb.addListener(new DWListener() {
					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
//							if(DWControlsManager.getInstance().contains(UIWindows.getInstance().m_recharge.m_recharge_Frame))
//							{
//								final DWMessageBox m_mb = new DWMessageBox("温馨提示", "充值界面还未关闭，确定操作完毕，现在退出副本吗？", "确定", "取消");
//								DWControlsManager.getInstance().addControl(m_mb);
//								m_mb.addListener(new DWListener() {
//
//									public void OnDoubleClick(){}
//
//									public void OnClick()
//									{
//										if(m_mb.getResult() == DWMessageBox.SOFTKEY_OK)
//										{
//											DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
//										}
//										else{}
//										DWControlsManager.getInstance().removeControl(m_mb);
//									}
//								});
//							}
//							else
//							{
//								DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
//							}
							DWGameManager.getInstance().getSendMessage().sendGameCarbonQuit();
							DWControlsManager.getInstance().removeControl(m_mb);
						}
						else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
							DWControlsManager.getInstance().removeControl(m_mb);
						}
					}
				});
				DWControlsManager.getInstance().addControl(m_mb);
			}
		}
	};

	private DWListener m_box_1_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_flag_1 == false) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "这个宝箱您已经开启，不能重复开启。");
			}
			else {
				DWGameManager.getInstance().getSendMessage().sendGameCarbonOpenBox((byte) 1);
			}
		}
	};

	private DWListener m_box_2_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_flag_2 == false) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "这个宝箱您已经开启，不能重复开启。");
			}
			else {
				final DWMessageBox m_mb = new DWMessageBox("温馨提示", "打开银宝箱，您" + GameCarbonBox2 + "确定开启此宝箱？", null, "确定");
				m_mb.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
							if (DWGameManager.getInstance().m_role.m_gold < GameCarbonBox2_money)
							{
								DWControlsManager.getInstance().removeControl(m_mb);
								DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B,
										"抱歉，您的金币不足，不能开启此宝箱。");
							}
							else
							{
								DWGameManager.getInstance().getSendMessage().sendGameCarbonOpenBox((byte) 2);
								DWControlsManager.getInstance().removeControl(m_mb);
							}
						}
					}
				});
				DWControlsManager.getInstance().addControl(m_mb);
			}
		}
	};

	private DWListener m_box_3_lis = new DWListener() {
		public void OnDoubleClick()
		{
		}

		public void OnClick()
		{
			if (m_flag_3 == false) {
				DWGameManager.getInstance().addSystemInfo(DWGameManager.SYSTEM_INFO_TYPE_B, "这个宝箱您已经开启，不能重复开启。");
			}
			else {
				final DWMessageBox m_mb = new DWMessageBox("温馨提示", "打开金宝箱，您" + GameCarbonBox3 + "确定开启此宝箱？", "确定", "返回");
				m_mb.addListener(new DWListener() {

					public void OnDoubleClick()
					{
					}

					public void OnClick()
					{
						if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK) {
							if (DWGameManager.getInstance().m_role.m_rmb < GameCarbonBox3_money)
							{
								DWControlsManager.getInstance().removeControl(m_mb);
								final DWMessageBox m_mb = new DWMessageBox("温馨提示", "抱歉，您的元宝不足，是否现在充值？", "确定", "取消");
								DWControlsManager.getInstance().addControl(m_mb);
								m_mb.addListener(new DWListener() {

									public void OnDoubleClick()
									{
									}

									public void OnClick()
									{
										if (m_mb.getResult() == DWMessageBox.SOFTKEY_OK)
										{
											//注释掉。。
//											if (ChannelOperation.isChanneSdkChongZhi) {
//												ChannelOperation.sdkPay();
//											}
//											else {
//												ChannelOperation.openChongZhiWindow();
//											}
										}
										else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK) {
										}
										DWControlsManager.getInstance().removeControl(m_mb);
									}
								});
							}
							else
							{
								DWGameManager.getInstance().getSendMessage().sendGameCarbonOpenBox((byte) 3);
								DWControlsManager.getInstance().removeControl(m_mb);
							}
						}
						else if (m_mb.getResult() == DWMessageBox.SOFTKEY_BACK)
						{
							DWControlsManager.getInstance().removeControl(m_mb);
						}
					}
				});
				DWControlsManager.getInstance().addControl(m_mb);
			}
		}
	};

	public void GameCarbonRewardDetails(final String key)
	{
		DWGameManager.getInstance().getSendMessage().sendGameCarbonReward_DetailS(key);
	}

	public void Update_data()
	{
		if (DWControlsManager.getInstance().contains(m_fuben_frame)) {
			if (m_jingli_textbox != null && m_fuben_frame.contains(m_jingli_textbox)) {
				m_jingli_textbox.setText(Integer.toString(DWGameManager.getInstance().m_role.m_jinglizhi_shengyu));
			}
		}
	}

	public static String getcolor(int index)
	{
		String color = "";
		switch (index) {
			case ItemConstants.稀有度_灰:
				color = "999999";
				break;
			case ItemConstants.稀有度_白:
				color = "ffffff";
				break;
			case ItemConstants.稀有度_蓝:
				color = "00BBFF";
				break;
			case ItemConstants.稀有度_绿:
				color = "55FF00";
				break;
			case ItemConstants.稀有度_紫:
				color = "9900FF";
				break;
			case ItemConstants.稀有度_橙:
				color = "FFBB11";
				break;
			case ItemConstants.稀有度_红:
				color = "FF3300";
				break;
		}
		return color;
	}
}
